Fix Device::availableMemory crash on Vulkan 1.0 instances#1712
Open
mbait wants to merge 1 commit into
Open
Conversation
vkGetPhysicalDeviceMemoryProperties2 and VkPhysicalDeviceMemoryBudgetPropertiesEXT were called unconditionally, but the former requires Vulkan 1.1 and the latter requires VK_EXT_memory_budget. On a 1.0 instance this triggered undefined behaviour and crashed Lavapipe during scene compilation. Gate the 1.1 path on both preconditions and fall back to vkGetPhysicalDeviceMemoryProperties with heap sizes when either is missing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Device::availableMemory()unconditionally callsvkGetPhysicalDeviceMemoryProperties2with a chainedVkPhysicalDeviceMemoryBudgetPropertiesEXT. Both have preconditions that are never checked:vkGetPhysicalDeviceMemoryProperties2requires Vulkan 1.1 (orVK_KHR_get_physical_device_properties2, promoted to core in 1.1).VkPhysicalDeviceMemoryBudgetPropertiesEXTrequires theVK_EXT_memory_budgetdevice extension.When a VSG application creates a
vsg::InstancewithVK_API_VERSION_1_0(still the default ofvsg::Instance::create), this function dispatches an unresolved entry point and feeds the driver a struct it never advertised support for. Behaviour is undefined. On Mesa Lavapipe it segfaults inside a driver worker thread during normal scene compilation (MemoryBufferPools::reserveBuffer->Device::availableMemory). The Khronos validation layer flags it as:Fix
Gate the 1.1 path on both
supportsApiVersion(VK_API_VERSION_1_1)andsupportsDeviceExtension(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME). When either is missing, fall back to the Vulkan 1.0vkGetPhysicalDeviceMemoryPropertiesand treatmemoryHeaps[i].sizeas the budget with zero live usage. The fallback returns a conservative upper bound — buffer pool sizing degrades gracefully instead of crashing.No public API changes. The 1.1 + extension code path is unchanged for users who request it.
Type of change
How Has This Been Tested?
Reproduced and verified on Mesa 25.2.8 Lavapipe (
lvp_icd.json) in a GPU-less Linux container with a minimal headless VSG application (vsg::Instance::create(..., VK_API_VERSION_1_0), offscreen framebuffer, oneBuilder::createSphereframe).libvulkan_lvp.soduringviewer->compile(), validation layer reports the API-version violation above.Test Configuration:
Checklist